package com.eascs.web.o2o.dc.common.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;



public class DateUtil {
	
	 public static String getSpecifiedDayBefore(int n) {//可以用new Date().toLocalString()传递参数  
	        Calendar c = Calendar.getInstance();  
	        Date date = new Date();  
	        c.setTime(date);  
	        int day = c.get(Calendar.DATE);  
	        c.set(Calendar.DATE, day - n);  
	  
	        String dayBefore = new SimpleDateFormat("yyyy-MM-dd").format(c  
	                .getTime());  
	        return dayBefore;  
	    }  
	 
	 
	 public static Date getSpecifiedDayBeforeDate(int n) {//可以用new Date().toLocalString()传递参数  
	        Calendar c = Calendar.getInstance();  
	        Date date = new Date();  
	        c.setTime(date);  
	        int day = c.get(Calendar.DATE);  
	        c.set(Calendar.DATE, day - n);  
	        return c.getTime();  
	    } 
	 
	  public static void main(String[] args) {
		  System.out.println( getSpecifiedDayBeforeDate(-1));
		 
	}

}
